from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, declarative_base

# ✅ MySQL连接配置
MYSQL_USER = "root"          # 你的数据库用户名
MYSQL_PASSWORD = "202267"  # 你的数据库密码
MYSQL_HOST = "localhost"     # 数据库地址
MYSQL_PORT = 3306            # 默认端口
MYSQL_DB = "ecg_platform"    # 数据库名（可自定义）

SQLALCHEMY_DATABASE_URL = (
    f"mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset=utf8mb4"
)

# ✅ 连接池设置建议
engine = create_engine(
    SQLALCHEMY_DATABASE_URL,
    pool_pre_ping=True,
    pool_recycle=3600,
)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
